from selenium import webdriver
from selenium.webdriver.common.by import By

'''
邓春梅
使用selenium
爬取24年cpi数据
'''

# 其他操作，如打开网页等
driver = webdriver.Chrome()

# 使用webdriver实例打开网页
driver.get('https://data.eastmoney.com/cjsj/cpi.html')
# 其他操作，如打开网页等
elements = driver.find_elements(By.XPATH, '//*[@id="cjsj_table"]/table/tbody/tr')[0:2]
dict()
for element in elements:
    consumer_price=element.text.split(" ")
    result={
        "consumer_price":consumer_price
    }
    print(result)
